<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <center>hello world</center>
    <button onclick="isMsg()">msg</button>
    <button onclick="files()">file</button>
    <button onclick="dirs()">dir</button>
    <button onclick="ceshi()">测试</button>
    <script>
        async function isMsg() {
            // 弹出消息框
            let msg = await win_alert("你好", 1)
            console.log(msg)
        }
        async function files() {
            // 弹出选择文件框
            let file = await win_file_dialog()
            console.log(file)
        }
        async function dirs() {
            // 弹出选择文件夹框
            let dir = await win_open_dir()
            console.log(dir)
        }
        async function ceshi() {
            let base = await win_read_bytes("asd.txt")
            let arr = JSON.parse(base);
            let bytes = new Uint8Array(arr); // UTF-8编码
            let decoder = new TextDecoder("utf-8");
            let str = decoder.decode(bytes);
            console.log(str); // 输出: 
        }
    </script>
</body>

</html>